package com.example.application.service;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
 * author: fangjie email: syfangjie@live.cn date: 2020/11/8 11:49 上午
 */
public class CSVService {
    private static final Map<String,String> map=new HashMap<>();

  public static void readCsv(String path)  {
    try( BufferedReader reader=new BufferedReader(new FileReader(path)) ) {
      while (reader.ready())
      {
        String line = reader.readLine();
        if(line==null)continue;
        String[] strs = line.split(",");
        if(strs.length!=2)continue;
        map.put(strs[0],strs[1]);
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
  }

  public static String query(String id){
      return map.getOrDefault(id,"not found !");
  }
}
